import 'package:casdon/core/logger/log.dart';
import 'package:casdon/core/network/business_exception.dart';
import 'package:casdon/modules/recipe/data/api/recipe_module_api.dart';
import 'package:casdon/modules/recipe/data/repository/recipe_repository.dart';

class RecipeModuleListUsecase {
  final RecipeRepository _repository;

  const RecipeModuleListUsecase(this._repository);

  Future<List<ResponseRecipeModuleApi>> execute() async {
    try {
      var ret = await _repository.getRecipeModuleList();
      ret ??= [];
      return ret;
    } on BusinessException {
      rethrow;
    } catch (e) {
      Log.e("RecipeModuleListUsecase 失败", e.toString(), StackTrace.current);
      throw Exception("RecipeModuleListUsecase 失败");
    }
  }
}
